<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="static/css/reset.css">
    <link rel="stylesheet" href="css/common.css" />
    <link rel="stylesheet" href="css/register.css" />
    <title>注册</title>
</head>

<body>
    <div class="register w12">
        <div class="register-main">
            <div class="main-left">
                <span>返回首页</span>
            </div>
            <div class="main-right">
                <div class="welcome">欢迎注册家教网</div>
                <div class="phone">
                    <input type="text" placeholder="请输入手机号码">
                </div>
                <div class="yzm">
                    <input type="text" placeholder="输入验证码">
                    <span>
                    <img src="static/img/validate-code.png" alt="">
                    </span>
                    <b>ewfresh</b>
                </div>
                <div class="phone-yzm">
                    <input type="text" id="phone" placeholder="输入验证码">
                    <span  onclick="yzm()" id="yzm">获取验证码</span>
                </div>
                <div class="psd">
                    <input type="password" placeholder="请输入密码">
                </div>
                <div class="psd">
                    <input type="repassword" placeholder="请再次输入密码">
                </div>
                <div class="promise">
                    <input type="checkbox" id="promise" />
                    <label for="promise">已阅读并同意<i>《家教网用户协议》</i></label>
                </div>
                <div class="next">
                    <button>下一步</button>
                </div>
                <div class="go-login">
                    我已注册，现在
                    <span>登录</span>
                </div>
            </div>
        </div>
    </div>
</body>
<script src='static/js/jquery.js'></script>
<script>
    function checkMobile(phone) {
    if (!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(phone))) {
        return 0;
    } else {
        return 1;
    }
}

function yzm() {
    console.log(checkMobile($("#phone").val()))
    if (checkMobile($("#phone").val()) == 1) {
        var time = 60;
        var timer = setInterval(function() {
            time--;
            if (time == 0) {
                clearInterval(timer)
                $("#yzm").text('获取验证码');
            } else {
                $("#yzm").text(time + 's');
            }
        }, 1000)
    }else{
        alert('请输入正确手机号码')
    }

}
</script>
<script src="js/common.js" type="text/javascript"></script>
</html>